﻿<UserControl x:Class="LiteralTextInputView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:view="clr-namespace:RegExUtility.View"
             xmlns:regex="clr-namespace:System.Text.RegularExpressions;assembly=System"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="400"
             d:DesignWidth="600">
    <Grid Margin="8">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100" />
            <ColumnDefinition MinWidth="100" />
        </Grid.ColumnDefinitions>

        <Border BorderBrush="#FF8C8E94"
                BorderThickness="1"
                Margin="0,0,6,0"
                Padding="4"
                SnapsToDevicePixels="True">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Label Content="Input" />

                <TextBox Text="{Binding InputText, UpdateSourceTrigger=PropertyChanged}"
                         Margin="0,0,0,8"
                         Grid.Row="1"
                         AcceptsReturn="True"
                         AcceptsTab="True"
                         HorizontalScrollBarVisibility="Visible"
                         VerticalScrollBarVisibility="Visible"
                         view:RegexTextBoxAdorner.IsRegexAdornerEnabled="{Binding Path=MatchesFound}"
                         view:RegexTextBoxAdorner.SelectionStart="{Binding Path=SelectedRegexItem.Index}"
                         view:RegexTextBoxAdorner.SelectionLength="{Binding Path=SelectedRegexItem.Length}"
                         BorderBrush="#FF828790" />

                <Button Content="Get Input Text from File"
                        Command="{Binding Path=Commands[OpenFile]}"
                        Grid.Row="2"
                        HorizontalAlignment="Right"
                        Width="144" />

            </Grid>
        </Border>

        <GridSplitter Width="4"
                      Grid.Column="1"
                      HorizontalAlignment="Left"
                      Margin="-1,0,0,0">

        </GridSplitter>

        <TabControl Grid.Column="1"
                    Margin="6,0,0,0">
            <TabItem Header="Matches">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>


                    <TreeView ItemsSource="{Binding MatchViewModels}"
                              SelectedItemChanged="TreeView_SelectedItemChanged" />

                    <Button Content="Find Matches"
                            IsDefault="True"
                            Command="{Binding Commands[Execute]}"
                            HorizontalAlignment="Right"
                            Width="144"
                            Grid.Row="1"
                            Margin="0,8,0,0" />


                </Grid>
            </TabItem>
            <TabItem Header="Replace">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Label Content="Replacement String" />

                    <TextBox Text="{Binding Path=ReplacementString}"
                             Grid.Row="1" />

                    <Label Content="Result"
                           Grid.Row="2" />

                    <TextBox Text="{Binding Path=ReplacementResult}"
                             Grid.Row="3"
                             IsReadOnly="True" />

                    <Button Content="Replace"
                            Command="{Binding Commands[Replace]}"
                            Grid.Row="4"
                            Margin="0,8,0,0" />


                </Grid>

            </TabItem>
        </TabControl>



    </Grid>
</UserControl>
